// 强制终止Goroutine
package main

import (
    "fmt"
    "runtime"
    "time"
)

func main() {
    go func() {
        defer fmt.Println("Goroutine1 defer...")
        for i:=0;i<10;i++{
            if i == 5{
                runtime.Goexit()
            }
            fmt.Println("Goroutine1: ",i)
        }
    }()

    go func() {
        fmt.Println("Goroutine 2")
    }()
    time.Sleep(5 * time.Second)
}
